package com.zlict.admin.controller;

import com.zlict.admin.domain.ProjectAcceptance;
import com.zlict.admin.service.IProjectAcceptanceService;
import com.zlict.common.annotation.Log;
import com.zlict.common.core.controller.BaseController;
import com.zlict.common.core.domain.AjaxResult;
import com.zlict.common.core.page.TableDataInfo;
import com.zlict.common.enums.BusinessType;
import com.zlict.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 项目验收Controller
 * 
 * @author dzw
 * @date 2025-06-11
 */
@RestController
@RequestMapping("/admin/acceptance")
public class ProjectAcceptanceController extends BaseController
{
    @Autowired
    private IProjectAcceptanceService projectAcceptanceService;

    /**
     * 查询项目验收列表
     */
    @PreAuthorize("@ss.hasPermi('admin:acceptance:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectAcceptance projectAcceptance)
    {
        startPage();
        List<ProjectAcceptance> list = projectAcceptanceService.selectProjectAcceptanceList(projectAcceptance);
        return getDataTable(list);
    }

    /**
     * 导出项目验收列表
     */
    @PreAuthorize("@ss.hasPermi('admin:acceptance:export')")
    @Log(title = "项目验收", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectAcceptance projectAcceptance)
    {
        List<ProjectAcceptance> list = projectAcceptanceService.selectProjectAcceptanceList(projectAcceptance);
        ExcelUtil<ProjectAcceptance> util = new ExcelUtil<ProjectAcceptance>(ProjectAcceptance.class);
        util.exportExcel(response, list, "项目验收数据");
    }

    /**
     * 获取项目验收详细信息
     */
    @PreAuthorize("@ss.hasPermi('admin:acceptance:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(projectAcceptanceService.selectProjectAcceptanceById(id));
    }

    /**
     * 新增项目验收
     */
    @PreAuthorize("@ss.hasPermi('admin:acceptance:add')")
    @Log(title = "项目验收", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectAcceptance projectAcceptance)
    {
        return toAjax(projectAcceptanceService.insertProjectAcceptance(projectAcceptance));
    }

    /**
     * 修改项目验收
     */
    @PreAuthorize("@ss.hasPermi('admin:acceptance:edit')")
    @Log(title = "项目验收", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectAcceptance projectAcceptance)
    {
        return toAjax(projectAcceptanceService.updateProjectAcceptance(projectAcceptance));
    }

    /**
     * 删除项目验收
     */
    @PreAuthorize("@ss.hasPermi('admin:acceptance:remove')")
    @Log(title = "项目验收", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(projectAcceptanceService.deleteProjectAcceptanceByIds(ids));
    }
}
